﻿// ----------------------------------------------------------------------
// <author name="Moses Kehengu"/>
// <copyright file="ListBoxItem.cs" company="Futures Group International">
//     Copyright statement. All right reserved
// </copyright>
//
// ------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GenericTools
{
    /// <summary>
    /// Ideal class for listbox item that may hold either region, district or facility
    /// </summary>
    public class ListBoxItem
    {
        #region Class Variables/Properties
        public object Value { get; set; }
        public string Text { get; set; }
        public int RegionID { get; set; }
        public int DistrictID { get; set; }
        public string FacilityCode { get; set; }
        #endregion

        #region Constructors
        /// <summary>
        /// Creates an empty object
        /// </summary>
        public ListBoxItem()
        {
            Value = null;
            Text = null;
            this.FacilityCode = null;
            this.RegionID = this.DistrictID = -1;
        }

        /// <summary>
        /// Creates an object with display text displayText and value value
        /// </summary>
        /// <param name="displayText">Display text</param>
        /// <param name="value">Object value</param>
        public ListBoxItem(string displayText, object value)
        {
            Text = displayText;
            this.Value = value;
        }

        /// <summary>
        /// Create an object with display text displayText and region ID regionID
        /// </summary>
        /// <param name="displayText">Display Text</param>
        /// <param name="regionID">Unique identifier of region</param>
        public ListBoxItem(string displayText, int regionID)
        {
            Text = displayText;
            this.Value = this.RegionID = regionID;
            this.DistrictID = -1;
            this.FacilityCode = null;
        }

        /// <summary>
        /// Creates object with display text displayText, region regionID and district districtID
        /// </summary>
        /// <param name="displayText">Display text</param>
        /// <param name="regionID">Unique identifier of region</param>
        /// <param name="districtID">Unique identifier of district</param>
        public ListBoxItem(string displayText, int regionID, int districtID)
        {
            Text = displayText;
            this.RegionID = regionID;
            this.Value = this.DistrictID = districtID;
            this.FacilityCode = null;
        }

        /// <summary>
        /// Creates an object with display text displayText, region regionID, district districtID and facility facilityCode
        /// </summary>
        /// <param name="displayText">Display Text</param>
        /// <param name="regionID">Unique identifier of region</param>
        /// <param name="districtID">Unique identifier of district</param>
        /// <param name="FacilityCode">Unique identifier of facility</param>
        public ListBoxItem(string displayText, int regionID, int districtID, string FacilityCode)
        {
            Text = displayText;
            this.RegionID = regionID;
            this.DistrictID = districtID;
            this.FacilityCode = FacilityCode;
            this.Value = FacilityCode;
        }
        #endregion

        #region Override Methods
        public override string ToString()
        {
            return Text;
        }
        #endregion
    }
}
